home *** CD-ROM | disk | FTP | other *** search
/ Exploring Creation with P…al Science (2nd Edition) / Exploring Creation with Physical Science (2nd Edition).iso / exe / bin / mplayerc.exe / FILE / 715 < prev    next >
Encoding:
Text File  |  2012-12-18  |  1.4 KB  |  51 lines

  1. sampler s0 : register(s0); 
  2. float4 p0 : register(c0); 
  3. float4 p1 : register(c1); 
  4.  
  5. #define width (p0[0]) 
  6. #define height (p0[1]) 
  7. #define counter (p0[2]) 
  8. #define clock (p0[3]) 
  9. #define one_over_width (p1[0]) 
  10. #define one_over_height (p1[1]) 
  11.  
  12. #define PI acos(-1) 
  13.  
  14. #define NbPixel      1 
  15.  
  16. #define Edge_threshold       0.2 
  17.  
  18. #define Sharpen_val0       2.0 
  19. #define Sharpen_val1       0.125 
  20.  
  21. float4 main(float2 tex : TEXCOORD0) : COLOR 
  22.    float dx = NbPixel/width; 
  23.    float dy = NbPixel/height; 
  24.    float4 Res = 0; 
  25.  
  26.    float4 c0 = tex2D(s0, tex); 
  27.    float4 c1 = tex2D(s0, tex + float2(-dx,-dy)); 
  28.    float4 c2 = tex2D(s0, tex + float2(0,-dy)); 
  29.    float4 c3 = tex2D(s0, tex + float2(dx,-dy)); 
  30.    float4 c4 = tex2D(s0, tex + float2(-dx,0)); 
  31.    float4 c5 = tex2D(s0, tex + float2(dx,0)); 
  32.    float4 c6 = tex2D(s0, tex + float2(-dx,dy)); 
  33.    float4 c7 = tex2D(s0, tex + float2(0,dy)); 
  34.    float4 c8 = tex2D(s0, tex + float2(dx,dy)); 
  35.  
  36.    float4 delta1 = (c6+c4+c1-c3-c5-c8); 
  37.    float4 delta2 = (c4+c1+c2-c5-c8-c7); 
  38.    float4 delta3 = (c1+c2+c3-c8-c7-c6); 
  39.    float4 delta4 = (c2+c3+c5-c7-c6-c4); 
  40.  
  41.    float value = length(abs(delta1) + abs(delta2) + abs(delta3) + abs(delta4))/6; 
  42.  
  43.    if(value > Edge_threshold ) 
  44.    { 
  45.       Res = c0 * Sharpen_val0 - (c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * Sharpen_val1 ; 
  46.       return Res; 
  47.    } 
  48.    else 
  49.       return c0; 
  50. }